function timeShow(){
    //获取当前时间
    var timeTemp = new Date();

    var year =timeTemp.getFullYear();

    var  month =timeTemp.getMonth()+1;

    var day = timeTemp.getDate();

    //提取当前时间的时分秒，注意小于10时的时间格式
    var hour = timeTemp.getHours();
    if(hour < 10){
        hour = "0" + hour;
    }
    var minute = timeTemp.getMinutes();
    if(minute < 10){
        minute = "0" + minute;
    }
    var second = timeTemp.getSeconds();
    if(second < 10){
        second = "0" + second;
    }

    //获取星期几，这里获得到的是数字1-7，所以我下面自己new了一个数组把获取到的数字当下标
    var weekend = timeTemp.getDay();

    var weeksAll = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");

    var weeks = weeksAll[weekend]//这样就是显示的星期x了

  //将日历的信息在这里进行获取
    var calendarJson = JSON.stringify(calendar.solar2lunar(), null, 4);
    var calendarObj = JSON.parse(calendarJson);
    // console.log(calendarObj)
    //console.log("农历节日:"+calendarObj.lunarFestival);
    if (calendarObj.lunarFestival != null) {
        var Lfestival ="农历节日:"+ calendarObj.lunarFestival;
    } else {
        Lfestival = "农历节日:无";
    }
    //console.log("节日:"+calendarObj.festival);
    if (calendarObj.festival != null) {
        var Yfestival = "阳历节日:"+calendarObj.festival;
    } else {
        Yfestival = "阳历节日:无";
    }

    //将提取的时分秒按照自己的想法进行拼接
    var nowTime = year+"年"+month+"月" +day+"日" +"&nbsp;&nbsp;&nbsp;&nbsp;"+ hour + ":" + minute + ":" + second +"&ensp;&ensp;&ensp;"+
        weeks +calendarObj.gzYear + "年" + calendarObj.IMonthCn + calendarObj.IDayCn + "(" + calendarObj.astro + ")" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + Lfestival + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + Yfestival;
    //通过id获取时间显示的对象引用
    var timeDiv = document.getElementById("showTime");
    //将拼接的字符串赋值给该id标签的HTML
    timeDiv.innerHTML = nowTime;
}
//每过1000毫秒执行一次该方法
window.setInterval(timeShow, 1000);


/*该代码原本存放在index界面，改进后可引用*/
/*
<li class="layui-nav-item" lay-unselect>
<a href="javascript:;">
    <span id="showTime" class="layui-nav-item"></span></a>
</li>*/
